package cn.dankal.lequ.ui.fragment.gamedetails_fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.dankal.lequ.R;
import cn.dankal.lequ.commom.adapter.BaseAdapter.ViewHolder;
import cn.dankal.lequ.commom.adapter.BaseAdapter.recyclerview.CommonAdapter;
import cn.dankal.lequ.ui.activity.GameDetailsActivity;

/**
 * 作者： fred on 16/4/19 11:21.
 * 邮箱：fred_kang@dankal.cn
 */
public class Gift_Fragment extends Fragment {

    @Bind(R.id.recyclerview)
    RecyclerView recyclerview;

    LinearLayoutManager linearLayoutManager;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.recyclerview, container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    private void initRecyclerView() {
        linearLayoutManager = new LinearLayoutManager(getActivity());
        recyclerview.setLayoutManager(linearLayoutManager);
        recyclerview.setHasFixedSize(true);
        List<String> mDatas = new ArrayList<>();
        mDatas.add("本周签到礼包");
        mDatas.add("本月签到礼包");
        mDatas.add("新人签到礼包");
        recyclerview.setAdapter(new CommonAdapter(getActivity(), R.layout.fragment_gamedetails_gift_item, mDatas) {

            @Override
            public void convert(ViewHolder holder, Object o) {
//                holder.setText(R.id.tv_title_gift,);
                holder.setImageResource(R.id.iv_gift1, R.mipmap.ic_bad_pressed);
                holder.setImageResource(R.id.iv_gift2, R.mipmap.iv_head_none);
                holder.setImageResource(R.id.iv_gift3, R.mipmap.ic_launcher);
                holder.setImageResource(R.id.iv_gift4, R.mipmap.ic_good_pressed);
                holder.setImageResource(R.id.iv_gift5, R.mipmap.ic_username);
                holder.setImageResource(R.id.iv_gift6, R.mipmap.ic_launcher);
                holder.setImageResource(R.id.iv_gift7, R.mipmap.ic_password);
                holder.setOnClickListener(R.id.iv_gift1, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Intent intent = new Intent(Gift_Fragment.this.getActivity(), GameDetailsActivity.class);
                        startActivity(intent);
                    }
                });
            }
        });
    }


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initRecyclerView();
    }
}
